package com.lenin.omena.shared.domain;

import java.io.Serializable;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class UserInfo implements Serializable, Comparable<UserInfo> {
	
	//private static final long serialVersionUID = 7440297955003302414L;
	

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY, defaultFetchGroup = "true")
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String key;
	
	@Persistent
	private String firstName;
	
	@Persistent
	private String lastName;
	
	@Persistent
	private String email;
	
	@Persistent
	private String phoneNumber;
	
	@Persistent
	private String userName;
	
	@Persistent
	private String password;
	
	@Persistent
	private String siteAddressKey;
	
	@NotPersistent
	private Address siteAddress;
	
	
	public UserInfo() {
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}


	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	
	public String getSiteAddressKey() {
		return siteAddressKey;
	}

	public void setSiteAddressKey(String siteAddressKey) {
		this.siteAddressKey = siteAddressKey;
	}
	
	public Address getSiteAddress() {
		return siteAddress;
	}

	public void setSiteAddress(Address siteAddress) {
		this.siteAddress = siteAddress;
	}

	public int compareTo(UserInfo hr) {
		return (hr == null || hr.firstName == null) ? -1
				: -hr.firstName.compareTo(firstName);
	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof UserInfo) {
			return key == ((UserInfo) o).key;
		}
		return false;
	}


}